#ifndef MOTIONCONSTRAINT_H
#define MOTIONCONSTRAINT_H

/***************************************************************************
			     MotionConstraint.h
                             -------------------
Copyright (c) 2009-2010 
Author: Kishor D. Bhalerao (kishor8dm@gmail.com)
Contributors: 

This file is associated with the Ph.D. dissertation,"ON METHODS FOR EFFICIENT
AND ACCURATE DESIGN AND SIMULATION OF MULTIBODY SYSTEMS", Bhalerao K.D,
Rensselaer Polytechnic Institute, 2010.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1.) Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2.) Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

3.) The name of the authors, their employers, or sponsoring organizations may
not be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHORS, THEIR EMPLOYERS, OR SPONSORING ORGANIZATIONS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/

#include <cstdlib>

using namespace std;
using namespace SimTK;

// Base class for motion constraints in DCA
class MotionConstraint{
	public:			
		// Constraint at position level
		virtual Real f(Real Time){
			cout<<"\nMotionConstraint.h: f(t) not defined\n";
			exit(1);
		}
		
		// Constraint at velocity level
		virtual Real fdot(Real Time){
			cout<<"\nMotionConstraint.h: fdot(t) not defined\n";
			exit(1);
		}
		
		// Constraint at acceleration level
		virtual Real fdotdot(Real Time){
			cout<<"\nMotionConstraint.h: fdotdot(t) not defined\n";
			exit(1);
		}
	
};

// Mohammads constraint function
class mCon: public MotionConstraint{
	public:
		mCon(const Real& a, const Real& w):a_(a),w_(w){}
		Real f(const Real& Time){return a_*(std::cos(w_*Time)-1);}
		Real fdot(const Real& Time){return -a_*w_*std::sin(w_*Time);}
		Real fdotdot(const Real& Time){return -a_*w_*w_*std::cos(w_*Time);}
	private:
		// Function is f = a*(cos(w*t)-1)
		Real a_,w_;
};

#endif